package com.icloud.cer.rest.util;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

public class ApplicationContextHelper implements ApplicationContextAware {

	private static ApplicationContext appContext;

	public static ApplicationContext getContext() {
		return appContext;
	}

	@SuppressWarnings("unchecked")
	public static <X> X getBean(String beanName) {
		return (X) getContext().getBean(beanName);
	}
	
	@SuppressWarnings("static-access")
	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		this.appContext = applicationContext;
	}

}
